/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.academik.validation;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.academik.controller.RecibosBean;
import org.academik.util.FacesUtil;

/**
 *
 * @author Javier
 */
@FacesValidator("recibosValidator")
public class RecibosValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
         RecibosBean e = (RecibosBean) FacesUtil.getBean("recibosBean");
        if (e.getArregloDetalles().isEmpty()) {
            FacesMessage msg = new FacesMessage("Error:", "Registre el cobro del recibo");
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }
    
}
